package com.wzy.service.base.handler;

import com.wzy.common.base.result.R;
import com.wzy.common.base.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import static com.wzy.common.base.result.ResultCodeEnum.EXCEPTION_ERROR;

/**
 * 2 * @Author: wuzhengyu
 * 3 * @Date: 2021/3/12 10:33
 * 4
 */
@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    public R error(Exception e) {
        e.printStackTrace();
        return R.error();
    }

    @ExceptionHandler(ArithmeticException.class)
    @ResponseBody
    public R error(ArithmeticException e) {
        e.printStackTrace();
        return R.setResult(EXCEPTION_ERROR);
    }



}
